#include <bits/stdc++.h>
using namespace std;
struct SegTree{
  SegTree *ls, *rs; int cnt;
  int64_t sum, pre, suf;
  SegTree(int l, int r): ls(nullptr), rs(nullptr), cnt(0), sum(0), pre(0), suf(0){
    if(r - l > 1){
      int mid = (l + r) >> 1;
      ls = new SegTree(l, mid);
      rs = new SegTree(mid, r);
    }
  }
  inline void pushUp(){
    sum = ls->sum + rs->sum, cnt = ls->cnt + rs->cnt;
    pre = ls->pre + rs->pre + ls->sum * rs->cnt;
    suf = ls->suf + rs->suf + rs->sum * ls->cnt;
    cnt = ls->cnt + rs->cnt;
  }
  void update(int x, int64_t v, int l, int r){
    if(r - l <= 1) return pre = suf = sum = (cnt = 1 - cnt) * v, void();
    int mid = (l + r) >> 1;
    if(x < mid) ls->update(x, v, l, mid);
    else        rs->update(x, v, mid, r);
    pushUp();
  }
  int64_t get_pre(int x, int l, int r){
    if(!x) return 0; else if(x == cnt) return sum;
    int mid = (l + r) >> 1, lv = min(x, ls->cnt);
    return (lv < ls->cnt? ls->get_pre(lv, l, mid): ls->sum) + (x > lv? rs->get_pre(x - lv, mid, r): 0);
  }
  int64_t get_suf(int x, int l, int r){
    if(!x) return 0; else if(x == cnt) return sum;
    int mid = (l + r) >> 1, rv = min(x, rs->cnt);
    return (x > rv? ls->get_suf(x - rv, l, mid): 0) + (rv < rs->cnt? rs->get_suf(rv, mid, r): rs->sum);
  }
  int64_t get_pre_2(int x, int l, int r){
    if(!x) return 0; else if(x == cnt) return pre;
    int mid = (l + r) >> 1, lv = min(x, ls->cnt);
    return ls->get_pre_2(lv, l, mid) + rs->get_pre_2(x - lv, mid, r) + ls->sum * (x - lv);
  }
  int64_t get_suf_2(int x, int l, int r){
    if(!x) return 0; else if(x == cnt) return suf;
    int mid = (l + r) >> 1, rv = min(x, rs->cnt);
    return ls->get_suf_2(x - rv, l, mid) + rs->get_suf_2(rv, mid, r) + rs->sum * (x - rv);
  }
};
constexpr int MAXN = 400005;
vector<int64_t> V;
int _; int64_t Q[MAXN];
int64_t query(SegTree &T){
  int n = T.cnt;
  if(n <= 1) return 0;
  int l = 1, r = n >> 1;
  while(l < r){
    int mid = (l + r) >> 1;
    if(T.get_suf(mid, 0, V.size()) > T.get_pre(mid + 1, 0, V.size())) r = mid; else l = mid + 1;
  }
  int l_ = l;
  l = n >> 1, r = n - 1;
  while(l < r){
    int mid = (l + r) >> 1;
    if(T.get_suf(mid, 0, V.size()) < T.get_pre(mid + 1, 0, V.size())) r = mid; else l = mid + 1;
  }
  int r_ = l;
  return T.get_suf_2(l_ - 1, 0, V.size()) - T.get_pre_2(l_ - 1, 0, V.size()) + T.get_suf(r_, 0, V.size()) - T.get_pre(l_, 0, V.size()) + T.get_suf_2(n, 0, V.size()) - T.get_suf_2(r_, 0, V.size()) - T.get_pre_2(n, 0, V.size()) + T.get_pre_2(r_, 0, V.size());
}
int main(){
  freopen("kte.in", "r", stdin);
  freopen("kte.out", "w", stdout);
  cin.tie(nullptr)->sync_with_stdio(false);
  cin >> _;
  for(int i = 1; i <= _; i++) cin >> Q[i], V.push_back(Q[i]);
  sort(V.begin(), V.end()), V.erase(unique(V.begin(), V.end()), V.end());
  SegTree T(0, V.size());
  for(int i = 1; i <= _; i++){
    T.update(lower_bound(V.begin(), V.end(), Q[i]) - V.begin(), Q[i], 0, V.size());
    cout << query(T) << '\n';
  }
  cerr << (double)clock() / CLOCKS_PER_SEC << endl;
  return 0;
}
